<?php
	$idmedico = $_GET['idmedico'];
	$usuario = $_GET['usuario'];
	include 'open-connection.php';

	// Performing SQL query
	if ($idmedico == 0) {
		$query = "SELECT COUNT(*) AS NUM FROM medico WHERE medico.usuario = '$usuario'";
	} else {
		$query = "SELECT COUNT(*) AS NUM FROM medico WHERE medico.usuario = '$usuario' AND medico.idmedico != $idmedico";
	}
	$result = mysql_query($query) or die('Query failed: ' . mysql_error());
	
	while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
		$arr[] = $line;
	}

	include 'close-connection.php';
	
	echo $arr[0]["NUM"];
?>